package zero.tech.core.data;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class Resp {
	protected String code; // 错误码

	protected String msg; // 消息

	protected JSONObject param; // 数据

	public static Resp build() {
		Resp bean = new Resp();
		return bean;
	}
	public static Resp build(Integer code, String msg) {
		return build(String.valueOf(code), msg);
	}
	public static Resp build(Integer code, String msg,Object data) {
		return build(String.valueOf(code), msg,data);
	}
	public static Resp build(String code, String msg) {
		Resp bean = new Resp();
		bean.code = code;
		bean.msg = msg;
		return bean;
	}
	
	public static Resp build(String code, String msg, Object data) {
		Resp bean = new Resp();
		bean.code = code;
		bean.msg = msg;
		if(data instanceof JSONObject) {
			bean.param = (JSONObject) data;
		}else {
			bean.param = (JSONObject) JSONObject.toJSON(data);
		}
		return bean;
	}

	public Resp() {
		super();
	}

	public String getCode() {
		return code;
	}

	public Resp setCode(String code) {
		this.code = code;
		return this;
	}

	public String getMsg() {
		return msg;
	}

	public Resp setMsg(String msg) {
		this.msg = msg;
		return this;
	}


	public JSON getParam() {
		return param;
	}

	public Resp setParam(JSONObject param) {
		this.param = param;
		return this;
	}
}
